<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018\9\18 0018
 * Time: 14:34
 */

namespace app\Lib\Ioc\Common;


use think\Db;

abstract class TransactionCommon
{
    public function run(){
        try {
            $transaction=Db::transaction(function(){
                $this->__before();
                $this->__run();
                $this->__beforeCommit();
                return true;
            });
            if($transaction)
            {
                $this->__successAfter();
            }
            $this->__after();

            return true;
        } catch (\Exception $e) {
            $this->__after();
            throw $e;
        }
    }
}